﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

using TravelSite.Entities;
using TravelSite.DAL;
using TravelSite.DAL.Repositories;
using Travel.Api.Code;

namespace Travel.Api.Controllers
{
    public class ClientController : ApiController
    {
        [HttpGet]
        [RequireHttps]
        public Contact Login(string ID)
        {
            using (var repo = RepositoryFactory.ResolveRepository<ApiContactRepository>())
            {
                Contact cnt = repo.FindByPin(ID);
                if (cnt != null)
                    return cnt;
                else
                {
                    throw new HttpResponseException(ErrorUtils.GetErrorResponse(ErrorCodes.NotValidPin));
                }
            }
        }

    }
}
